/**
 * @class Ext.form.DcDateField
 * @extends Ext.form.DateField
 * Provides a date input field with a {@link Ext.DatePicker} dropdown and automatic date validation.
 * @constructor
 * Create a new DateField
 * @param {Object} config
 */
Ext.form.DcDateField = Ext.extend(Ext.form.DateField,  {
		defaultAutoCreate : {tag: "input", type: "text", size: "10", readonly: "true" ,autocomplete: "off"},
		setValue : function(date){
        if(date instanceof Date){
        	Ext.form.DateField.superclass.setValue.call(this, date.dateFormat('Y-m-d'));
        }else{
        	if(date.length>10) date=date.substring(0,10);
					Ext.form.DateField.superclass.setValue.call(this, this.formatDate(this.parseDate(date)));       
        }    
    },
		
    /**
     * Returns the current date value of the date field.
     * @return {Date} The date value
     */
    getValue : function(){
        return Ext.form.DateField.superclass.getValue.call(this);
    },
    onTriggerClick : function(){
        if(this.disabled){
            return;
        }
        if(this.menu == null){
            this.menu = new Ext.menu.DateMenu();
        }
        Ext.apply(this.menu.picker,  {
            minDate : this.minValue,
            maxDate : this.maxValue,
            disabledDatesRE : this.ddMatch,
            disabledDatesText : this.disabledDatesText,
            disabledDays : this.disabledDays,
            disabledDaysText : this.disabledDaysText,
            format : this.format,
            minText : String.format(this.minText, this.formatDate(this.minValue)),
            maxText : String.format(this.maxText, this.formatDate(this.maxValue))
        });
        this.menu.on(Ext.apply({}, this.menuListeners, {
            scope:this
        }));
        this.menu.picker.setValue((this.getValue() instanceof Date ? this.getValue():this.parseDate(this.getValue()))|| new Date());
        this.menu.show(this.el, "tl-bl?");
    }
});